1 Imports System.Data.SqlClient
2 Imports System.Security.Cryptography
3 Imports System.IO
4 Imports System.Text
5 Public Class frmActivation
6
7 Private Sub frmActivation_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
8 Try
9 Dim i As System.Management.ManagementObject
10 Dim searchInfo_Processor As New System.Management.ManagementObjectSearcher("Select * from Win32_Processor")
11 For Each i In searchInfo_Processor.Get()
12 txtHardwareID.Text = i("ProcessorID").ToString
13 Next
14 Dim searchInfo_Board As New System.Management.ManagementObjectSearcher("Select * from Win32_BaseBoard")
15 For Each i In searchInfo_Board.Get()
16 txtSerialNo.Text = i("SerialNumber").ToString
17 Next
18 Catch ex As Exception
19 MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
20 End
21 End Try
22 End Sub
23
24 Private Sub btnClose_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
25 End
26 End Sub
27
28 Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
29 Try
30 If txtActivationID.Text = "" Then
31 MessageBox.Show("Please enter activation id", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
32 txtActivationID.Focus()
33 Exit Sub
34 End If
35 Dim st As String = (txtHardwareID.Text) + (txtSerialNo.Text)
36 TextBox1.Text = Encryption.MakePassword(st, 659)
37 If txtActivationID.Text = TextBox1.Text Then
38 con = New SqlConnection(cs)
39 con.Open()
40 Dim cb1 As String = "insert into Activation(HardwareID,SerialNo,ActivationID) VALUES (@d1,@d2,@d3)"
41 cmd = New SqlCommand(cb1)
42 cmd.Connection = con
43 cmd.Parameters.AddWithValue("@d1", txtHardwareID.Text)
44 cmd.Parameters.AddWithValue("@d2", txtSerialNo.Text)
45 cmd.Parameters.AddWithValue("@d3", Encrypt(txtActivationID.Text.Trim()))
46 cmd.ExecuteReader()
47 con.Close()
48 MessageBox.Show("Successfully activated", "Software", MessageBoxButtons.OK, MessageBoxIcon.Information)
49 frmLogin.Show()
50 Me.Hide()
51 Else
52 MessageBox.Show("Invalid activation id...Please contact software provider for buying full licence" & vbCrLf & "Contact us at :" & vbCrLf & "Care Infosoft" & vbCrLf & "Email-Carecomputeruna@gmail.com" & vbCrLf & "Mobile No. +919727762216", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
53 End If
54 Catch ex As Exception
55 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
56 End Try
57 End Sub
58 End Class